package com.administrator.customviewtest.view_group;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.widget.LinearLayout;

/**
 * Created by Administrator on 2017/2/17.
 */

public class ChatPopLayout extends LinearLayout {

    private Paint paint;
    private Path path;
    private int radius = 20;
    private int width,height;

    public ChatPopLayout(Context context) {
        super(context);
        init();
    }


    public ChatPopLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public ChatPopLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        paint = new Paint();
        paint.setAntiAlias(true);
        paint.setColor(Color.RED);
        paint.setStyle(Paint.Style.FILL);
        paint.setStrokeWidth(2);

        path = new Path();
    }


    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        height = getMeasuredHeight()-17;
        width = getMeasuredWidth()-2;
        canvas.translate(1,1);

        canvas.drawColor(Color.WHITE);

        path.moveTo(-radius,0);
        path.quadTo(0,0,radius,0);
        path.lineTo(width-radius,0);
        path.quadTo(width,0,width,radius);
        path.lineTo(width,height-radius);
        path.quadTo(width,height,width-radius,height);
        path.lineTo(width-radius-10,height);
        //三角形
        path.lineTo(width-radius-20,height+15);
        path.lineTo(width-radius-30,height);
        path.lineTo(radius,height);
        path.quadTo(0,height,0,height-radius);
        path.close();
        canvas.drawPath(path,paint);


    }
}
